package adv5;

import java.io.*;

public class Read2 {

	public static void main(String[] args) {
		try {
			InputStream in = new FileInputStream("E:\\作业\\java56\\11-17-作业.txt");
			byte[] b = new byte[30];
			int len = 0;
			// /返回值是实际读取的字节数
			// 错误
			// for (byte b1 : b) {
			// System.out.print((char) b1 + " ");
			// }
			while ((len = in.read(b)) > -1) {
				System.out.println("读取了" + len + "个字节：");
				// for (int i = 0; i < len; i++) {
				// System.out.print((char) b[i] + " ");
				// }
				String s = new String(b, 0, len, "gbk");
				System.out.println(s);
			}

			in.close();// 不合适的
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}

	}
}
